Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transfer class #310

Merged
merged 2 commits into from
Feb 29, 2024
Merged

transfer class #310

merged 2 commits into from
Feb 29, 2024

Conversation

SKairinos
Copy link
Contributor

@SKairinos SKairinos commented Feb 26, 2024

This change is Reviewable

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @SKairinos)


backend/api/serializers/klass.py line 35 at r1 (raw file):

    def validate_teacher(self, value: Teacher):
        user = self.request.school_teacher_user
        if value.school_id != user.teacher.school_id:

Shall we do just school instead of school_id?


backend/api/tests/views/test_klass.py line 105 at r1 (raw file):

    def test_create__other(self):
        """
        Teacher can create a class with another teacher as the class owner.

Admin teacher

@SKairinos
Copy link
Contributor Author

backend/api/serializers/klass.py line 35 at r1 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Shall we do just school instead of school_id?

Generally speaking, it's more efficient to compare 2 related objects by their iIDs as you avoid fetching the related objects from the db. Also it does the same equality comparison under the hood anyway so it's logically the same check.

This will not call the db to fetch the school objects and check the ids

value.school_id != user.teacher.school_id

This call the db to fetch the 2 school objects (so 2 db calls) and then check the ids (under the hood it's doing value.school.id != user.teacher.school.id)

value.school != user.teacher.school

Copy link
Contributor Author

@SKairinos SKairinos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 of 4 files reviewed, 2 unresolved discussions (waiting on @faucomte97)


backend/api/tests/views/test_klass.py line 105 at r1 (raw file):

Previously, faucomte97 (Florian Aucomte) wrote…

Admin teacher

Done.

Copy link
Contributor

@faucomte97 faucomte97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @SKairinos)

@SKairinos SKairinos merged commit 6a262fa into development Feb 29, 2024
3 of 4 checks passed
@SKairinos SKairinos deleted the transfer_class branch February 29, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants